import {
  MALL_MANAGEMENT_TITLE,
  GOODS_STATUS,
  BOOK_DETAIL,
  BOOK_LOADING
} from '@/Redux/ActionTypes/MallManagement/MallManagementActionTypes'
import initialState from '@/Redux/initialState';


// eslint-disable-next-line import/no-anonymous-default-export
export default (state = initialState.mallManagement, action) => {
  switch (action.type) {
    case MALL_MANAGEMENT_TITLE: {
      let newState = {
        ...state
      };
      newState.mall_title = action.mall_title
      return newState
    }
    case GOODS_STATUS: {
      let newState = {
        ...state
      };
      newState.goods_status = action.goods_status
      return newState
    }
    case BOOK_DETAIL: {
      let newState = {
        ...state
      };
      newState.book_detail = {
        url: action.book_detail.url,
        title: action.book_detail.title,
        writer: action.book_detail.writer,
        type: action.book_detail.type,
        introduce: action.book_detail.introduce,
        publisher: action.book_detail.publisher,
        price: action.book_detail.price,
        discount: action.book_detail.discount,
        discountedPrice: action.book_detail.discountedPrice,
      }
      return newState
    }
    case BOOK_LOADING: {
      let newState = {
        ...state
      };
      newState.book_loading = action.book_loading
      return newState
    }
    default: {
      return state
    }
  }
}